from django.db import models

# Create your models here.

# from django.db import models
#
#
# class TextInput(models.Model):
#     original_text = models.TextField()
#     segmented_text = models.TextField()
#     created_at = models.DateTimeField(auto_now_add=True)
#
#     def __str__(self):
#         return self.original_text[:50]  # return first 50 characters


# from django.db import models
#
# class TextEntry(models.Model):
#     original_text = models.TextField()
#     segmented_text = models.TextField()
#     part_of_speech = models.TextField()
#     # created_at = models.DateTimeField(auto_now_add=True)
#
#     def __str__(self):
#         return self.original_text
from django.db import models

# class TextEntry(models.Model):
#     original_text = models.TextField()
#     segmented_text = models.TextField()
#     part_of_speech = models.TextField()
#
#     def __str__(self):
#         return self.original_text[:50]  # 显示前50个字符作为字符串表示


# models.py
from django.db import models


class TextEntry(models.Model):
    original_text = models.TextField()
    segmented_text = models.TextField()
    part_of_speech = models.TextField()
    word_frequency = models.JSONField(default=dict)  # 使用JSONField存储词频数据

    def __str__(self):
        return self.original_text[:50]  # 仅显示前50个字符用于管理界面

from django.contrib.auth.models import User

# 帮助文档模型
class HelpDocument(models.Model):
    title = models.CharField(max_length=200)
    content = models.TextField()

    def __str__(self):
        return self.title




# text_analysis/models.py

from django.db import models



# text_analysis/models.py
class AnalysisFeedback(models.Model):
    feedback = models.TextField("用户反馈", help_text="请留下您的反馈意见。")
    created_at = models.DateTimeField(auto_now_add=True, verbose_name="提交时间")

    class Meta:
        db_table = 'analysis_feedback'  # 确保使用你期望的表名

    def __str__(self):
        return f"反馈时间: {self.created_at}"


from django.db import models

class CustomUser(models.Model):
    username = models.CharField(max_length=150, unique=True)
    email = models.EmailField(unique=True)
    password = models.CharField(max_length=255)

    class Meta:
        db_table = 'analysis_CustomUser'  # 指定表名


# import hanlp
#
# # 加载模型
# tokenizer = hanlp.load('CTB6_CONVSEG')
# pos_tagger = hanlp.load('CTB9_CON_ELECTRA_SMALL')
#
# # 测试文本
# original_text = "北京是中国的首都。"
# segmented = tokenizer(original_text)
# pos_tags = pos_tagger(segmented)

# print(f"分词: {segmented}")
# print(f"词性标注: {pos_tags}")